<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>视频面签</title>
    %{--<link rel="icon" href="${createLinkTo(dir: "images", file: "favicon.ico")}" type="image/x-icon">--}%
    %{--<link rel="shortcut icon" href="${createLinkTo(dir: 'images', file: 'favicon.ico')}" type="image/x-icon"/>--}%
    <asset:stylesheet src="homer/vendor/fontawesome/css/font-awesome.min.css"/>
    <asset:stylesheet src="homer/vendor/metisMenu/dist/metisMenu.min.css"/>
    <asset:stylesheet src="homer/vendor/bootstrap/dist/css/bootstrap.min.css"/>
    <asset:stylesheet src="homer/style.css"/>
    <asset:stylesheet src="homer/vendor/sweetalert/lib/sweet-alert.css"/>
    <asset:stylesheet src="homer/vendor/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"/>
    <asset:stylesheet src="highlight/styles/atelier-seaside-light.css"/>
    <asset:stylesheet src="homer/vendor/select2-3.5.2/select2.min.css"/>
    <asset:stylesheet src="homer/vendor/select2-3.5.2/select2-bootstrap.css"/>
    <asset:stylesheet src="homer/vendor/ladda/ladda-themeless.min.css"/>
    <asset:stylesheet src="homer/vendor/datetimepicker/bootstrap-datetimepicker.min.css"/>
    <asset:stylesheet src="homer/vendor/datetimepicker/bootstrap-datepicker3.min.css"/>
    <asset:stylesheet src="homer/vendor/summernote/summernote.css"/>
    <asset:stylesheet src="homer/vendor/bootstrap-touchspin/jquery.bootstrap-touchspin.min.css"/>
    <asset:stylesheet src="homer/vendor/cropper/cropper.min.css"/>
    <asset:stylesheet src="homer/vendor/cropper/uploadAvater.css"/>
    <asset:stylesheet src="homer/main.css"/>
    <asset:javascript src="homer/vendor/jquery/dist/jquery.min.js"/>
    <asset:stylesheet src="homer/vendor/toastr/toastr.min.css"/>

    <g:layoutHead/>


</head>

<body class="fixed-navbar fixed-sidebar fixed-footer hide-sidebar">

<div class="splash">

    <div class="splash-title">

        <div class="spinner"><div class="rect1"></div>

            <div class="rect2"></div>

            <div class="rect3"></div>

            <div class="rect4"></div>

            <div class="rect5"></div>
        </div>
    </div>
</div>

<div id="header" style="z-index:1">
    <div class="color-line">
    </div>
    <div id="logo" class="light-version">
        <span>
            <a href="/welcome" style="font-size: large;">LMS</a>
        </span>
    </div>
    <nav role="navigation">
        <div class="header-link hide-menu" style="padding-bottom: 22px;"><i class="fa fa-bars"></i></div>
        <div class="small-logo">
            <span class="text-primary" style="font-size: large;">LMS</span>
        </div>

        <div class="mobile-menu">
            <button type="button" class="navbar-toggle mobile-menu-toggle" data-toggle="collapse" style="margin-top:0"
                    data-target="#mobile-collapse">
                <sec:ifLoggedIn>
                    <asset:image src="defaultAvater.png" class="img-circle" alt="logo" width="32" height="32"/><b
                        class="caret"></b>
                </sec:ifLoggedIn>
            </button>

            %{--<div class="collapse mobile-navbar" id="mobile-collapse">
                <ul class="nav navbar-nav new-dropdown">
                    <li><a href="#"><i class="fa fa-edit"></i>更换头像</a></li>
                    <li>
                        <g:link controller="user" action="changePassword">
                            <i class="fa fa-gear"></i>修改口令
                        </g:link>
                    </li>
                    <li>
                        <g:link controller="logoff">
                            <i class="fa fa-sign-out"></i>退出</g:link>
                    </li>
                </ul>
            </div>--}%
        </div>

        <div class="navbar-right" id="header-right" style="margin-right: 20px;">

            <ul class="nav navbar-nav no-borders">
                <sec:ifLoggedIn>
                     %{--<sec:ifNotGranted roles="ROLE_ADMINISTRATOR, ROLE_GENERAL_MANAGER, ROLE_COO ">
                        <li class="dropdown">
                            <a class="dropdown-toggle label-menu-corner" href="#" data-toggle="dropdown">
                                <i class="fa fa-envelope-o"></i>
                                <span class="label label-info">${com.next.OpportunityRole.findAll("from OpportunityRole where user.id = ? and stage.id = opportunity.stage.id and opportunity.status = 'Pending'", [com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.id])?.size()}</span>
                            </a>
                            <ul class="dropdown-menu hdropdown animated flipInX">
                                <div class="title">
                                    您有<b
                                        class="text-info">${com.next.OpportunityRole.findAll("from OpportunityRole where user.id = ? and stage.id = opportunity.stage.id and opportunity.status = 'Pending'", [com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.id])?.size()}</b>个代办事项

                                </div>
                                <g:each in="${com.next.OpportunityStage.list()}">
                                    <g:if test="${com.next.OpportunityRole.findAll("from OpportunityRole where user.id = ? and stage.id = opportunity.stage.id and stage.id = ? and opportunity.status = 'Pending'", [com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.id, it?.id])?.size() > 0}">
                                        <li>
                                            <g:link controller="OpportunityRole" action="searchOpportunity"
                                                    params="[stage: it?.name]">
                                                ${it?.name} (${com.next.OpportunityRole.findAll("from OpportunityRole where user.id = ? and stage.id = opportunity.stage.id and stage.id = ? and opportunity.status = 'Pending'", [com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.id, it?.id])?.size()})
                                            </g:link>
                                        </li>
                                    </g:if>
                                </g:each>
                            </ul>
                        </li>
                    </sec:ifNotGranted>--}%
                    <li class="dropdown">
                        <a class="dropdown-toggle dropdown-link" href="#" data-toggle="dropdown">
                            <g:if test="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.avatarUrl}">
                                <img src="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.avatarUrl}" class="img-circle" alt="logo" width="32" height="32"/>
                            </g:if>
                            <g:else>
                                <asset:image src="defaultAvater.png" class="img-circle" alt="logo" width="32" height="32"/>
                            </g:else>
                            <span style="font-size: 16px"><sec:loggedInUserInfo field="username"/></span><b
                                style="margin-top: 3px;" class="caret"></b>
                        </a>
                        <ul class="dropdown-menu new-dropdown hdropdown animated flipInX">
                            %{--<li>
                                <a href="#" id="replaceImg"><i class="fa fa-lg fa-gear"></i>修改头像</a>
                                <g:link controller="user" action="changeAvater">
                                    <i class="fa fa-lg fa-gear"></i>修改头像
                                </g:link>

                                <a href="#" id="crop-avatar" data-toggle="modal" data-target="#avatar-modal"><i class="fa fa-lg fa-edit"></i>更换头像</a>
                            </li>--}%
                            <li>
                                <g:link controller="user" action="changePassword">
                                    <i class="fa fa-lg fa-gear"></i>修改口令
                                </g:link>
                            </li>
                            <li>
                                <g:link controller="logoff">
                                    <i class="fa fa-lg fa-sign-out"></i>退出</g:link>
                            </li>
                        </ul>
                    </li>

                </sec:ifLoggedIn>
            </ul>
        </div>

    </nav>
</div>
<!-- Navigation -->
%{--<sec:ifLoggedIn>--}%

    <aside id="menu">
    <div id="navigation">
      <ul class="nav" id="side-menu">
        %{--<g:if test="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.dynamicMenu}">
          <g:each in="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.getMenuArr()}">
            <g:if test="${it.children.size() != 0}">
                <li>
                    <a id="menu_${it.id}" href="${it.url}">
                        <span class="nav-label">
                        <g:if test="${it?.icon}">
                          <i class="${it?.icon}"></i>
                        </g:if>
                        <g:else>
                        <i class="fa fa-lg fa-fw fa-info-circle"></i>
                        </g:else>
                            ${it.title}
                          </span>
                        <span class="fa arrow"></span>
                    </a>
                    <ul class="nav nav-second-level">

                      <g:each in="${it.children.grep{a -> a.status == 1 ? true : false}.sort{a,b -> a.orderNum < b.orderNum ? -1 : 1}}" var="cit">
                          <li>
                              <a id="menu_${cit.id}" href="${cit.url}" parentid="menu_${it.id}">${cit.title}</a>
                          </li>
                      </g:each>
                    </ul>
                </li>
              </g:if>
              <g:else>
                  <li>
                    <a id="menu_${it.id}" href="${it.url}">
                      <g:if test="${it?.icon}">
                        <i class="${it?.icon}"></i>
                      </g:if>
                      <g:else>
                      <i class="fa fa-lg fa-fw fa-info-circle"></i>
                      </g:else>
                      ${it.title}
                    </a>
                  </li>
              </g:else>
          </g:each>
        </g:if>--}%
          <li>
              <a href="interviewList">
                  <span class="nav-label">
                      <i class="fa fa-lg fa-fw fa-bars"></i>面谈列表
                  </span>
              </a>
          </li>
          <li>
              <a href="remoteSignface">
                  <span class="nav-label">
                      <i class="fa fa-lg fa-fw fa-smile-o"></i>视频面签
                  </span>
              </a>
          </li>
      </ul>
    </div>

    </aside>
%{--</sec:ifLoggedIn>--}%
<sec:ifNotLoggedIn>
    <script>
        window.location.href("/login/auth");
    </script>
</sec:ifNotLoggedIn>
<div id="wrapper">

    <g:layoutBody/>
</div>

%{--<div class="modal fade" id="myModaDocument" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="color-line"></div>

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"
                                                                                                  class="text-info">×</span>
                </button>
                <h4 class="modal-title">帮助文档</h4>
            </div>

            <div class="modal-body document-body" id="document-body">
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <g:form class="form-horizontal" controller="opportunity" action="cancel"
                    id="${this.opportunity?.id}">
                <div class="color-line"></div>

                <div class="modal-header">
                    <h4 class="modal-title">失败原因</h4>
                </div>

                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">失败原因</label>

                        <div class="col-sm-10">
                            <g:select class="form-control" name="causeOfFailure"
                                      value="${this.opportunity?.causeOfFailure?.id}"
                                      noSelection="${['null': '无']}"
                                      from="${com.next.CauseOfFailure.list()}" optionKey="id"
                                      optionValue="name"></g:select>
                        </div>
                    </div>

                    <div class="hr-line-dashed"></div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注</label>

                        <div class="col-sm-10">
                            <g:textArea class="form-control" name="descriptionOfFailure" required=""
                                        value="${this.opportunity?.descriptionOfFailure}"
                                        rows="6"/>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">保存</button>
                </div>
            </g:form>
        </div>
    </div>
</div>

<div class="modal fade" id="rejectReason" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <g:form class="form-horizontal" controller="opportunity" action="reject">
                <input type="hidden" name="opportunity" value="${this.opportunity?.id}" id="opportunity">

                <div class="color-line"></div>

                <div class="modal-header">
                    <h4 class="modal-title">返回原因</h4>
                </div>

                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">返回原因</label>

                        <div class="col-sm-10">
                            --}%%{--<g:each in="${this.opportunityFlows}">
                                <g:if test="${it?.stage == this.opportunity?.stage}">
                                    <g:textArea class="form-control" name="comments" required=""
                                                value="${it?.comments}"
                                                rows="6"/>
                                </g:if>
                            </g:each>--}%%{--
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">保存</button>
                </div>
            </g:form>
        </div>
    </div>
</div>

<div class="modal fade" id="rejectReason2" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <g:form class="form-horizontal" controller="opportunity" action="ajaxReject">
                <input type="hidden" name="opportunity" value="${this.opportunity?.id}" id="opportunity">

                <div class="color-line"></div>

                <div class="modal-header">
                    <h4 class="modal-title">返回原因</h4>
                </div>

                <div class="modal-body">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">返回原因</label>

                        <div class="col-sm-10">
                            --}%%{--<g:each in="${this.opportunityFlows}">
                                <g:if test="${it?.stage == this.opportunity?.stage}">
                                    <g:textArea class="form-control" name="comments" required="" id="comments"
                                                value="${it?.comments}"
                                                rows="6"/>
                                </g:if>
                            </g:each>--}%%{--
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary rejectBtn">保存</button>
                </div>
            </g:form>
        </div>
    </div>
</div>

<div class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <g:form class="form-horizontal approveForm" controller="opportunity" id="${this.opportunity?.id}"
                    action="approve">
                <input type="hidden" name="nextStage" value="" id="nextStage">
                <input type="hidden" name="nextOperator" value="" id="nextOperator">

                <div class="color-line"></div>

                <div class="modal-header">
                    <h4 class="modal-title">提交下一步</h4>
                </div>

                <div class="modal-body form-horizontal">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">下一阶段名称：</label>

                        <div class="col-sm-9">
                            <span id="nextStepInfo" class="cont"></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">下一阶段操作人：</label>

                        <div class="col-sm-9">
                            <span id="nextOperatorInfo" class="cont"></span>
                        </div>
                    </div>

                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary">提交</button>
                </div>
            </g:form>
        </div>
    </div>
</div>

<div class="modal fade" tabindex="-1" id="applyForAmendment" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <g:form controller="house" id="${this.opportunity?.id}" action="modifyCollateralInformation">
                <div class="color-line"></div>

                <div class="modal-header">
                    <h4 class="modal-title">申请修改押品信息</h4>
                </div>

                <div class="modal-body">
                    <div class="form-group">
                        <label>请输入修改信息和修改原因</label>
                        <g:textArea class="textarea form-control" rows="5" name="applyReasonAndContent" value=""
                                    id="applyReasonAndContent"/>

                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </g:form>
        </div>
    </div>
</div>
<!--图片裁剪框 start-->
<div style="display: none" class="tailoring-container">

    <div class="black-cloth" onclick="closeTailor(this)"></div>

    <div class="tailoring-content">
        <div class="tailoring-content-one">
            <label title="上传图片" for="chooseImg" class="btn btn-info choose-btn">
                <input type="file" accept="image/jpg,image/jpeg,image/png" name="file" id="chooseImg"
                       class="hidden" onchange="selectImg(this)">
                选择图片
            </label>

            <div class="close-tailoring" onclick="closeTailor(this)">×</div>
        </div>

        <div class="tailoring-content-two">
            <div class="tailoring-box-parcel">
                <g:if test="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.avatarUrl}">
                    <img id="tailoringImg" src="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.avatarUrl}" alt="avatar" width="308" height="308"/>
                </g:if>
                <g:else>
                    <asset:image id="tailoringImg" src="defaultAvater.png" alt="avatar" width="308" height="308"/>
                </g:else>
            </div>

            <div class="preview-box-parcel">
                <p>图片预览：</p>

                <div class="square previewImg"></div>

                <div class="circular previewImg"></div>
            </div>
        </div>

        <div class="tailoring-content-three">
            <button class="btn btn-primary cropper-reset-btn">复位</button>
            <button class="btn btn-primary cropper-rotate-btn">旋转</button>
            <button class="btn btn-primary cropper-scaleX-btn">换向</button>
            <button class="btn btn-success sureCut" id="sureCut">确定</button>
        </div>
    </div>
</div>--}%
%{--<aside id="menu" style="width: 180px;">
    <div id="navigation">
        <ul class="nav" id="side-menu">
            <g:if test="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.dynamicMenu}">
                <g:each in="${com.next.User.findByUsername(sec.loggedInUserInfo(field: 'username'))?.getMenuArr()}">
                    <g:if test="${it.children.size() != 0}">
                        <li>
                            <a id="menu_${it.id}" href="${it.url}">
                                <span class="nav-label">
                                    <g:if test="${it?.icon}">
                                        <i class="${it?.icon}"></i>
                                    </g:if>
                                    <g:else>
                                        <i class="fa fa-lg fa-fw fa-info-circle"></i>
                                    </g:else>
                                    ${it.title}
                                </span>
                                <span class="fa arrow"></span>
                            </a>
                            <ul class="nav nav-second-level">

                                <g:each in="${it.children.grep{a -> a.status == 1 ? true : false}.sort{a,b -> a.orderNum < b.orderNum ? -1 : 1}}" var="cit">
                                    <li>
                                        <a id="menu_${cit.id}" href="${cit.url}" parentid="menu_${it.id}">${cit.title}</a>
                                    </li>
                                </g:each>
                            </ul>
                        </li>
                    </g:if>
                    <g:else>
                        <li>
                            <a id="menu_${it.id}" href="${it.url}">
                                <g:if test="${it?.icon}">
                                    <i class="${it?.icon}"></i>
                                </g:if>
                                <g:else>
                                    <i class="fa fa-lg fa-fw fa-info-circle"></i>
                                </g:else>
                                ${it.title}
                            </a>
                        </li>
                    </g:else>
                </g:each>
            </g:if>

           --}%%{-- <li>
                <a href="interviewMessage">
                    <span class="nav-label">
                        <i class="fa fa-lg fa-fw fa-user-md"></i>面谈详情
                    </span>
                </a>
            </li>--}%%{--

        </ul>
    </div>

</aside>--}%
<asset:javascript src="homer/vendor/cropper/cropper.min.js"/>

<asset:javascript src="homer/vendor/jquery-ui/jquery-ui.min.js"/>
<asset:javascript src="homer/vendor/bootstrap/dist/js/bootstrap.min.js"/>
<asset:javascript src="homer/vendor/jquery-validation/jquery.validate.min.js"/>
<asset:javascript src="homer/vendor/metisMenu/dist/metisMenu.min.js"/>
<asset:javascript src="homer/vendor/sweetalert/lib/sweet-alert.min.js"/>
<asset:javascript src="homer/vendor/select2-3.5.2/select2.min.js"/>
<asset:javascript src="homer/vendor/select2-3.5.2/select2_locale_zh-CN.js"/>
<asset:javascript src="homer/vendor/iCheck/icheck.min.js"/>
<asset:javascript src="homer/vendor/ladda/spin.min.js"/>
<asset:javascript src="homer/vendor/ladda/ladda.min.js"/>
<asset:javascript src="homer/vendor/ladda/ladda.jquery.min.js"/>
<asset:javascript src="homer/homer.js"/>
<asset:javascript src="highlight.pack.js"/>
<asset:javascript src="homer/vendor/datetimepicker/bootstrap-datetimepicker.min.js"/>
<asset:javascript src="homer/vendor/datetimepicker/bootstrap-datetimepicker.zh-CN.js"/>
<asset:javascript src="homer/vendor/datetimepicker/bootstrap-datepicker.min.js"/>
<asset:javascript src="homer/vendor/datetimepicker/bootstrap-datepicker.zh-CN.min.js"/>
<asset:javascript src="homer/vendor/summernote/summernote.min.js"/>
<asset:javascript src="homer/vendor/summernote/summernote-zh-CN.min.js"/>
<asset:javascript src="homer/vendor/toastr/toastr.min.js"/>

<asset:javascript src="homer/vendor/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js"/>
<script>
    $(function () {
        toastr.options = {
            "debug": false,
            "newestOnTop": false,
            "positionClass": "toast-top-center",
            "closeButton": true,
            "toastClass": "animated fadeInDown",
        };
        //获取押品价格
        $.each($(".housesExternalId"), function (i, obj) {
            var externalId = $(obj).text().trim();
            if (externalId) {
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    url: "/house/queryValuationReliability",
                    data: {
                        externalId: $(obj).text().trim()
                    },
                    success: function (data) {
                        if (data.status == "success") {
                            var unitPrice = data.pvCollateral.unitPrice;
                            var valuationReliability = data.pvCollateral.valuationReliability;
                            var area = $(obj).nextAll(".area").text().trim();
                            var pvTotalPrice = unitPrice * area;
                            $(obj).nextAll(".latestCollateralPrice").text(pvTotalPrice.toFixed(2));
                            $(obj).nextAll(".valuationReliability").text(valuationReliability);

                        }
                    },
                });
            }

        });


        var selectRole = $(".selectRole");
        for (var i = 0; i < selectRole.length; i++) {
            var n = selectRole.eq(i).children("option").length;
            if (n <= 1) {
                selectRole.eq(i).addClass("hide");
            }
        }
        $(".nextStepBtn").click(function () {
            var nextStepBtnText = $(this).val();
            $("#nextStage").val(nextStepBtnText);
            var nextOperatorBtnText = $(this).prevAll(".selectRole").val();

            $("#nextOperator").val(nextOperatorBtnText);
            $.ajax({
                type: "POST",
                dataType: "json",
                url: "/opportunity/prepareApprove",
                data: {
                    opportunityId: $("#opportunityId").val(),
                    nextStageId: $(this).val(),
                    nextOperatorId: $(this).prevAll(".selectRole").val()
                },

                success: function (data) {
                    if (data.status == "success") {
                        $("#nextStepInfo").text(data.nextStep);
                        $("#nextOperatorInfo").text(data.nextOperator);
                        $(".approveForm").submit();
                    }
                    else {
                        swal(data.errMsg, "", "error");
                    }
                },
                error: function () {
                    swal("获取失败，请稍后重试", "", "error");
                }
            });
        });

        $(".nextStepBtn2").click(function () {
            var nextStage = $(this).val();
            var nextOperator = $(this).prevAll(".selectRole").val();
            swal({
                    title: "是否确认提交",
                    type: "warning",
                    showCancelButton: true,
                    showConfirmButton: false,
                    confirmButtonColor: "#3aa9dd",
                    confirmButtonText: "确认",
                    closeOnConfirm: false,
                    cancelButtonText: "取消",
                    showLoaderOnConfirm:true,
                },
                function(isConfirm){
                    if (isConfirm) {
                        var laddaBtn = document.querySelector('button.ladda-button');
                        if (laddaBtn) {
                            var spinner = Ladda.create(laddaBtn);
                        }
                        $.ajax({
                            type: "POST",
                            dataType: "json",
                            url: "/opportunity/ajaxApprove",
                            data: {
                                opportunityId: $("#opportunityId").val(),
                                nextStage: nextStage,
                                nextOperator: nextOperator
                            },
                            beforeSend: function () {
                                if (laddaBtn && spinner) {
                                    spinner.start();
                                }

                            },
                            success: function (data) {
                                if (data.status == "success") {
                                    if (laddaBtn && spinner) {
                                        spinner.stop();
                                    }
                                    swal("提交成功", "下一阶段责任人： " + data.nextOperator, "success");
                                    $(".sweet-alert .confirm").click(function () {
                                        window.history.go(0);
                                    })

                                }
                                else {
                                    if (laddaBtn && spinner) {
                                        spinner.stop();
                                    }
                                    swal(data.errMsg, "", "error");
                                }
                            },
                            error: function () {
                                if (laddaBtn && spinner) {
                                    spinner.stop();
                                }
                                swal("获取失败，请稍后重试", "", "error");
                            }
                        });
                    }
                });
        });

        $(".rejectBtn").click(function () {

            $.ajax({
                type: "POST",
                dataType: "json",
                url: $(this).closest("form").attr("action"),
                data: {
                    opportunityId: $("#opportunityId").val(),
                    comments: $(this).closest("form").find("#comments").val()
                },

                success: function (data) {
                    if (data.status == "success") {

                        swal("提交成功", "上一阶段责任人： " + data.foreOperator, "success");
                        $(".sweet-alert .confirm").click(function () {
                            window.history.go(0);
                        })

                    }
                    else {
                        swal("回退失败", data.errMsg, "error");
                    }
                },
                error: function () {
                    swal("获取失败，请稍后重试", "", "error");
                }
            });
        });


        $(".interestEventEvaluate").click(function () {
            swal({
                    title: "是否确认提交",
                    type: "warning",
                    showCancelButton: true,
                    showConfirmButton: false,
                    confirmButtonColor: "#3aa9dd",
                    confirmButtonText: "确认",
                    closeOnConfirm: false,
                    cancelButtonText: "取消",
                    showLoaderOnConfirm:true,
                },
                function(isConfirm){
                    if (isConfirm) {
                        /*var laddaBtn = document.querySelector('button.ladda-button');
                        if (laddaBtn) {
                            var spinner = Ladda.create(laddaBtn);
                        }*/
                        $.ajax({
                            type: "POST",
                            dataType: "json",
                            url: "/opportunityProduct/eventEvaluate",
                            data: {
                                opportunityId: $("#opportunityId").val(),
                            },
                            /*beforeSend: function () {
                                if (laddaBtn && spinner) {
                                    spinner.start();
                                }

                            },*/
                            success: function (data) {
                                if (data.status == 100) {

                                    /*if (laddaBtn && spinner) {
                                        spinner.stop();
                                    }*/
                                    swal(data.msg, "", "error");
                                }else if(data.status == 200){
                                    window.history.go(0);
                                }
                            },
                            error: function () {
                                /*if (laddaBtn && spinner) {
                                    spinner.stop();
                                }*/
                                swal("获取失败，请稍后重试", "", "error");
                            }
                        });
                    }
                })});
//        帮助文档
        var text = $("#document").val();
        $("#document-body").html(text);
//        折叠
        $(".collapsed .showhide").click(function () {
            $(this).parent().parent().toggleClass("hbuilt");
            $(this).parent().parent().parent().toggleClass("panel-collapse");
        });
        $("select").select2();
//        代码高亮
        hljs.initHighlightingOnLoad();
//删除数据
        $(document).delegate(".deleteBtn", "click", function () {
            var currentForm = $(this).parent("form");
            swal({
                    title: "您确认删除该数据吗?",
                    type: "warning",
                    showCancelButton: true,
                    confirmButtonColor: "#DD6B55",
                    cancelButtonText: "取消",
                    confirmButtonText: "删除",
                    closeOnConfirm: false,
                    closeOnCancel: true

                },
                function (isConfirm) {
                    if (isConfirm) {
                        currentForm.submit();
                    }
                });

        });
    });
    //    日期插件
    $('.form_datetime').datetimepicker({
        minView: "day", //选择日期后，不会再跳转去选择时分秒
        format: "yyyy-mm-dd hh:00:00", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true //选择日期后自动关闭
    });
    $('.form_datetime3').datetimepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        format: "yyyy-mm-dd", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true //选择日期后自动关闭
    });
    $('.form_datetime2').datetimepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        format: "yyyy-mm-dd 00:00:00", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true //选择日期后自动关闭
    });
    $('.form_endtime').datetimepicker({
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        format: "yyyy-mm-dd 23:59:59", //选择日期后，文本框显示的日期格式
        language: 'zh-CN', //汉化
        autoclose: true //选择日期后自动关闭
    });
    $('a.page-scroll').bind('click', function (event) {
        var link = $(this);
        $('html, body').stop().animate({
            scrollTop: $(link.attr('href')).offset().top - 115
        }, 500);
        event.preventDefault();
    });
    $('body').scrollspy({
        target: '#navbar-example',
        offset: 125
    });
    //押品
    $.each($(".collateral .collateralOrder"), function (i, obj) {
        $(obj).text(i + 1);
    });
    var status = $(".collateralStatus").text();
    $.each($(".collateral .collateralStatus"), function (i, obj) {
        var status = $(obj).text();
        if (status == "Failed") {
            $(obj).removeClass("text-info").addClass("text-danger");
        }
    });
    //订单审批意见隐藏
    if ($(".commentsContent").children().length < 1) {
        $(".commentsContent").closest(".commentsRow").remove();
    }
    // $(".table-responsive").parent(".panel-body").addClass("active");
    //执行顺序
    $("input[name='executeSequence']").TouchSpin({
        verticalbuttons: true,
        min: -100000,
    });
    $("input[name='executionSequence']").TouchSpin({
        verticalbuttons: true,
        min: 1,
        max: 10000
    });
    //还款计划修改
    $(".billsItemsChangeStatus").click(function () {
        var billItemId = $(this).parent().prevAll("input[name='billItemId']").val();
        var dataName = $(this).attr("name");
        $.ajax({
            type: "POST",
            data: {
                name: dataName,
                dataName: $(this)[0].checked,
                billItemId: billItemId
            },
            cache: false,
            url: "/billsItem/updateStatus",
            dataType: "JSON",
            success: function (data) {
                if (data.status == "success") {
                    swal(data.msg, "", "success");
                } else {
                    swal(data.msg, "", "error");
                }
            },
            error: function () {
                swal("获取失败，请稍后重试", "", "error");
            }
        });

    });

//    过滤条件按钮操作
    $(".filterPaneTable").find("input").addClass("form-control");
    $(".filterpane .buttons").find("input[value='Cancel']").addClass("btn-danger btn-xs").val("取消");
    $(".filterpane .buttons").find("input[value='Clear']").addClass("btn-warning btn-xs").val("清空");
    $(".filterpane .buttons").find("input[value='清空']").click(function () {
        $("#filterPaneForm select").select2("val", "");

    });
    $(".filterpane .buttons").find("input[value='Apply']").addClass("btn-success btn-xs").val("确认");
</script>




<script>
    $(function () {
        $("#side-menu").find("li").each(function () {
            var a = $(this).find("a:first")[0];
            if ($(a).attr("href") === location.pathname+location.search) {
                // console.log('一样的url',$(this).parents()[0])
                $(this).parents().css('display','block');
            } else {
                // console.log('不一样的url',$(a).attr("href"),location.pathname+location.search)
            }
        });
    })
    window.onclick = function () {
        $("#side-menu li ul").attr("aria-expanded", "false")
        $("#side-menu li ul").hide();
        $("#side-menu li").removeClass("active")
    }
    $("#side-menu>li").on("click",function (e) {
        if($(this).children("ul").css('display') == "block"){
            $(this).children("ul").hide();
            $(this).removeClass("active")
        }else{
            $(this).children("ul").removeClass("in")
            $(this).children("ul").show()
            $(this).children("ul").attr("aria-expanded", "true")
            $(this).addClass("active")
        }
        $(this).siblings().children('ul').hide();
        e.stopPropagation()
    })
</script>


%{--不动产导航代码--}%
<script>
    //nav
    $(function() {
        $('.parentMenu').mouseover(function() {
            $(this).children(".childMenu").show();
        }).mouseout(function() {
            $(this).children(".childMenu").hide();
        });
        $('#loginName').mouseover(function() {
            $('#loginNameSel').show();
        }).mouseout(function() {
            $('#loginNameSel').hide();
        });



        // 激活父菜单
        function activeParentMenu(){
            var liAList = $('.navSelect a');
            var isActive = false;
            // 方案1按照子菜单地址索引父菜单的方法来激活
            for(var i=0;i<liAList.length;i++){
                var self = $(liAList[i]);
                if(location.href.indexOf(self.attr('href')) != -1){
                    if(self.attr("parentid") != undefined){
                        //var pid = self.attr("parentid");
                        self.parent().parent().parent().addClass("active");
                        isActive = true;
                    }
                    else{
                        self.parent().addClass("active");
                        isActive = true;
                    }
                    break;
                }
            }
            // 如果方案1不行，就方案2：按照父节点的activeUrl判断当前url
            if(isActive == false){
                for(var i=0;i<liAList.length;i++){
                    var self = $(liAList[i]);
                    if(self.attr('activeUrl')!="" && location.pathname.indexOf(self.attr('activeUrl')) == 0){
                        self.parent().addClass("active");
                        isActive = true;
                        break;
                    }
                }
            }
            //如果方案2也行不通,那就方案3：自己手动编写激活映射
            if(isActive == false){
                cusActiveParentMenu();
            }
        }
        // 自定义激活父菜单
        function cusActiveParentMenu(){
            var targetUrl = location.href;
            if(targetUrl.indexOf('/opportunityTeam') > -1){
                //$(".navSelect a[activeUrl='/opportunityTeam']").parent().addClass("active");
                //$(".parentMenu a")[0].className += 'active';
            }
        }
        activeParentMenu();
        $(".dropdown-content").eq(1).css("margin-left","-33px");
        $(".dropdown-content").eq(2).css("margin-left","-24px");
        $(".dropdown-content").eq(3).css("margin-left","-24px");
        $(".dropdown-content").eq(4).css("margin-left","-24px");
    });

    //弹出框水平垂直居中
    (window.onresize = function () {
        var win_height = $(window).height();
        var win_width = $(window).width();
        if (win_width <= 768) {
            $(".tailoring-content").css({
                "top": (win_height - $(".tailoring-content").outerHeight()) / 2,
                "left": 0
            });
        } else {
            $(".tailoring-content").css({
                "top": (win_height - $(".tailoring-content").outerHeight()) / 2,
                "left": (win_width - $(".tailoring-content").outerWidth()) / 2
            });
        }
    })();

    //弹出图片裁剪框
    $("#replaceImg").on("click", function () {
        $(".tailoring-container").toggle();
    });

    //图像上传
    function selectImg(file) {
        if (!file.files || !file.files[0]) {
            return;
        }
        var reader = new FileReader();
        reader.onload = function (evt) {
            var replaceSrc = evt.target.result;
            //更换cropper的图片
            $('#tailoringImg').cropper('replace', replaceSrc, false);//默认false，适应高度，不失真
        }
        reader.readAsDataURL(file.files[0]);
    }

    //cropper图片裁剪
    $('#tailoringImg').cropper({
        aspectRatio: 1 / 1,//默认比例
        preview: '.previewImg',//预览视图
        guides: false,  //裁剪框的虚线(九宫格)
        autoCropArea: 0.5,  //0-1之间的数值，定义自动剪裁区域的大小，默认0.8
        movable: false, //是否允许移动图片
        dragCrop: true,  //是否允许移除当前的剪裁框，并通过拖动来新建一个剪裁框区域
        movable: true,  //是否允许移动剪裁框
        resizable: true,  //是否允许改变裁剪框的大小
        zoomable: false,  //是否允许缩放图片大小
        mouseWheelZoom: false,  //是否允许通过鼠标滚轮来缩放图片
        touchDragZoom: true,  //是否允许通过触摸移动来缩放图片
        rotatable: true,  //是否允许旋转图片
        crop: function (e) {
            // 输出结果数据裁剪图像。
        }
    });
    //旋转
    $(".cropper-rotate-btn").on("click", function () {
        $('#tailoringImg').cropper("rotate", 45);
    });
    //复位
    $(".cropper-reset-btn").on("click", function () {
        $('#tailoringImg').cropper("reset");
    });
    //换向
    var flagX = true;
    $(".cropper-scaleX-btn").on("click", function () {
        if (flagX) {
            $('#tailoringImg').cropper("scaleX", -1);
            flagX = false;
        } else {
            $('#tailoringImg').cropper("scaleX", 1);
            flagX = true;
        }
        flagX != flagX;
    });

    //裁剪后的处理
    $("#sureCut").on("click", function () {
        if ($("#tailoringImg").attr("src") == null) {
            return false;
        } else {
            var canvas = $('#tailoringImg').cropper('getCroppedCanvas');//获取被裁剪后的canvas
            var base64url = canvas.toDataURL('image/png'); //转换为base64地址形式
            $("#finalImg").prop("src", base64url);//显示为图片的形式
            canvas.toBlob(function (blob) {
                var formData = new FormData();
                formData.append('avatar', blob, 'avatar.jpg');
                $.ajax('/user/saveAvater', {
                    method: 'POST',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function (data) {
                        if (data.status == "success") {
                            swal("提交成功", "" , "success");
                            $(".sweet-alert .confirm").click(function () {
                                window.history.go(0);
                            })

                        }
                    },
                    error: function () {
                        swal("上传失败，请稍后重试", "", "error");
                    }


                });
            });


            //关闭裁剪框
            closeTailor();
        }
    });

    //关闭裁剪框
    function closeTailor() {
        $(".tailoring-container").toggle();
    }


</script>

</body>
</html>
